#ifndef EVENTLOOPTHREADPOOL_HPP
#define EVENTLOOPTHREADPOOL_HPP

#include <memory>
#include <vector>
#include <assert.h>
#include "EventLoop.hpp"
#include "EventLoopThread.hpp"

// 线程池的本质是生产者消费者模型
class EventLoopThreadPool {
public:
    EventLoopThreadPool(int numThreads);
    ~EventLoopThreadPool() { LOG << "~EventLoopThreadPool()"; }
    // noncopyable
    EventLoopThreadPool(const EventLoopThreadPool&) = delete;
    EventLoopThreadPool& operator=(const EventLoopThreadPool&) = delete;

    void start();
    sp_EventLoop getNextLoop();
    void stop();

private:
    int numThreads_;
    int index_;
    std::vector<std::shared_ptr<EventLoopThread>> threads_;
};

#endif // EVENTLOOPTHREADPOOL_HPP